<%@ Import Namespace="MvcContrib.FluentHtml"%>
<%@ Control Language="C#" AutoEventWireup="true"
	Inherits="System.Web.Mvc.ViewUserControl<ETestIT.Web.Controllers.CandidatesController.CandidateFormViewModel>" %>
<%@ Import Namespace="ETestIT.Core" %>
<%@ Import Namespace="ETestIT.Web.Controllers" %>
 

<% if (ViewContext.TempData[ControllerEnums.GlobalViewDataProperty.PageMessage.ToString()] != null) { %>
    <p id="pageMessage"><%= ViewContext.TempData[ControllerEnums.GlobalViewDataProperty.PageMessage.ToString()]%></p>
<% } %>

<%= Html.ValidationSummary() %>

<% using (Html.BeginForm()) { %>
    <%= Html.AntiForgeryToken() %>
    <%= Html.Hidden("Candidate.Id", (ViewData.Model.Candidate != null) ? ViewData.Model.Candidate.Id : 0)%>

	<label for="Candidate_FirstName">FirstName:</label>
		<%= Html.TextBox("Candidate.FirstName", 
			(ViewData.Model.Candidate != null) ? ViewData.Model.Candidate.FirstName.ToString() : "")%>
    <br/>

    <label for="Candidate_Surename">Surename:</label>
		<%= Html.TextBox("Candidate.Surename", 
			(ViewData.Model.Candidate != null) ? ViewData.Model.Candidate.Surename.ToString() : "")%>
	<br/>

	<label for="Candidate_Email">Email:</label>
		<%= Html.TextBox("Candidate.Email", 
			(ViewData.Model.Candidate != null) ? ViewData.Model.Candidate.Email.ToString() : "")%>
	<br/>

	<label for="Candidate_Phone">Phone:</label>
		<%= Html.TextBox("Candidate.Phone", 
			(ViewData.Model.Candidate != null) ? ViewData.Model.Candidate.Phone.ToString() : "")%>
	<br/>
    
	<label for="Candidate_Category">Category:</label>
        <%= this.Select("Candidate.Category").Attr("size", 1).Options<CandidateCategories>()%>
	<br/>

	<label for="Candidate_ProfileTitle">ProfileTitle:</label>
		<%= this.Select("Candidate.ProfileTitle").Attr("size", 1).Options(ViewData.Model.Titles, c => c.Id, c => c.Name)
		    .Selected((ViewData.Model.Candidate != null) ? ViewData.Model.Candidate.ProfileTitle.Id : 0)%>
	<br/>

    <%= Html.SubmitButton("btnSave", "Save") %>
    <%= Html.Button("btnCancel", "Cancel", HtmlButtonType.Button, 
		    "window.location.href = '" + Html.BuildUrlFromExpression<CandidatesController>(c => c.Index(null)) + "';") %>
    <br />
    <br />
<% } %>
